package thread;

class MyRunnable implements Runnable{
    @Override
    public void run() {
        while(true){
            System.out.println("Thread");
            try{
                Thread.sleep(1000);
            }
            catch (InterruptedException e){
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        }
    }
}

public class Demo2_runnable {
    public static void main(String[] args) throws InterruptedException{
        Runnable r = new MyRunnable();
        Thread t = new Thread(r);
        t.start();
        while(true){
            System.out.printf("Main");
            Thread.sleep(1000);
        }
    }
}
